# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
pkgname=oscam
verbase=1.20
pkgver=1.20_svn20190731
pkgrel=0
pkgdesc="An Open Source Conditional Access Module software"
url="http://www.streamboard.tv/oscam/"
arch="all"
license="GPL"
depends=""
depends_dev=""
makedepends="
	subversion
	linux-headers
	openssl-dev
	libusb-dev
	pcsc-lite-dev
	"
install="$pkgname.pre-install"
pkgusers="$pkgname"
subpackages="$pkgname-doc $pkgname-list-smargo:list_smargo $pkgname-dbg
	$pkgname-openrc
"
svnurl="http://www.streamboard.tv/svn/oscam/trunk"
disturl="dev.alpinelinux.org:/archive/$pkgname/"
source="https://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	$pkgname.conf
	"

builddir="$srcdir"/oscam-$pkgver

build() {
	cd "$builddir"
	make allyesconfig
	make OSCAM_BIN=oscam \
		LIST_SMARGO_BIN=list_smargo \
		CONF_DIR=/etc/oscam \
		USE_LIBUSB=1 \
		USE_PCSC=1 \
		DEFAULT_PCSC_FLAGS="-I/usr/include/PCSC"
}

package() {
	cd "$builddir"
	install -d "$pkgdir"/var/log/$pkgname/cw \
		"$pkgdir"/var/run/$pkgname \
		"$pkgdir"/usr/share/doc/oscam/example \
		"$pkgdir"/usr/share/doc/oscam/monitor \
		"$pkgdir"/usr/share/man/man1 \
		"$pkgdir"/usr/share/man/man5
	install -m644 "$builddir"/Distribution/doc/txt/* \
		"$pkgdir"/usr/share/doc/oscam/
	install -m644 "$builddir"/Distribution/doc/example/* \
		"$pkgdir"/usr/share/doc/oscam/example/
	install -m644 "$builddir"/Distribution/monitor/* \
		"$pkgdir"/usr/share/doc/oscam/monitor/
	install -m644 "$builddir"/Distribution/doc/man/*.1 \
		"$pkgdir"/usr/share/man/man1/
	install -m644 "$builddir"/Distribution/doc/man/*.5 \
		"$pkgdir"/usr/share/man/man5/
	install -D -m755 "$builddir/oscam" \
		"$pkgdir/usr/bin/oscam"
	install -D -m644 "$srcdir"/$pkgname.conf \
		"$pkgdir"/etc/$pkgname/$pkgname.conf
	chown -R $pkgname "$pkgdir"/var/*/$pkgname \
		"$pkgdir"/etc/$pkgname
	install -D -m755 "$srcdir"/$pkgname.initd \
                "$pkgdir"/etc/init.d/$pkgname
        install -D -m644 "$srcdir"/$pkgname.confd \
                "$pkgdir"/etc/conf.d/$pkgname
}

list_smargo() {
	pkgdesc="Tool to identify your smargo card reader"
	install -m755 -D "$builddir"/list_smargo \
		"$subpkgdir"/usr/bin/list_smargo
}

dbg() {
	mkdir -p "$subpkgdir"/usr/bin
	mv "$builddir"/oscam.debug \
		"$subpkgdir"/usr/bin
}

check() {
	"$builddir"/oscam --build-info > /dev/null
}

sha512sums="f2c383ecaa056efa57b1ca5cf42bf832f501a7e96776f19efa6a151dfd59d4ffe8a013f36ab7b52eadbf38b87754ad98c0c413eb654727536d3fcc2122b4d2d2  oscam-1.20_svn20190731.tar.gz
869d51a2e8472011ecc5b9776e5cb6dbbc87a648bb025f5c0d7c26147e4c1eb91c7d4a4f780237c9996e218bda0025107a921f14a55cf014a1f39d97e4422c4b  oscam.initd
73998e9b9212c4868284aa4ed7d3a53fb61c087658f6dd8615de331fe12e1a9a1ea8941ebcc880804579d161d7954ead098315130cd07fc0fb2b368475f74e96  oscam.confd
0f3c4b9940bd27169dfe934599525558bc712d43f07959f19dce6ccfbf0e4d35d345272500fba2bff30e4ecf23f11f72b75321f8a45df908373620349d7f8808  oscam.conf"
